package com.leoandroid.tool.toolsbox.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.leoandroid.tool.toolsbox.bean.ZodiacBean
import com.leoandroid.tool.toolsbox.largeread.R
import com.leoandroid.tool.toolsbox.largeread.databinding.AdapterZodiacAgeBinding

class ZodiacDetailAdapter(val context:Context, val currentAge:ArrayList<ZodiacBean.ZodiacSubBean>): RecyclerView.Adapter<ZodiacDetailAdapter.Holder>() {

    inner class Holder(itemView:View):RecyclerView.ViewHolder(itemView){

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val inflater = DataBindingUtil.inflate<AdapterZodiacAgeBinding>(LayoutInflater.from(context),
            R.layout.adapter_zodiac_age,parent,false)
        return Holder(inflater.root)
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
        val dataBind:AdapterZodiacAgeBinding?= DataBindingUtil.getBinding(holder.itemView)
        dataBind?.apply {
            ageTv.text = "年龄"+currentAge[position].y
            shiTv.text = "实岁"+currentAge[position].s
            xuTv.text = "虚岁"+currentAge[position].x
        }
    }

    override fun getItemCount(): Int {
        return currentAge.size
    }
}